﻿using System.Linq;
using System.Threading;
using CommonBehaviors.Actions;
using PvPRogue.Helpers;
using PvPRogue.Managers;
using PvPRogue.Spec;
using PvPRogue.Utils;
using PvPRogue;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.Pathing;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

/*namespace PvPRogue.Managers
{
    public static class Poisons2
    {
        private static readonly uint[] InstantID = { 6947, 43231 };
        private static readonly uint[] MindNumbingID = { 5237 };
        private static readonly uint[] DeadlyID = { 2892, 43233 };
        private static readonly uint[] WoundID = { 10918, 43235 };

        public static bool NeedPoisonMainHand
        {
            get
            {
                return StyxWoW.Me.Inventory.Equipped.MainHand != null &&
                    StyxWoW.Me.Inventory.Equipped.MainHand.TemporaryEnchantment.Id == 0 &&
                    StyxWoW.Me.Inventory.Equipped.MainHand.ItemInfo.WeaponClass != WoWItemWeaponClass.FishingPole;
                
            }
        }
        
        public static bool NeedOffHandPoison
        {
            get
            {
                return StyxWoW.Me.Inventory.Equipped.OffHand != null &&
                    StyxWoW.Me.Inventory.Equipped.OffHand.TemporaryEnchantment.Id == 0;
            }
        }

        private static int MainHandPoison
        {
            get
            {
                switch (ClassSettings._Instance.SubtletyMainPoison)
                {

                    case ePoison.Wound:
                        return 8679;
                    case ePoison.Deadly:
                        return 2823;
                    default:
                        return 0;
                }
            }
        }
        private static int OffHandHandPoison
        {
            get
            {
                switch (ClassSettings._Instance.SubtletyOffHandPoison)
                {
                    case ePoison.MindNumbing:
                        return 5761;
                    case ePoison.Crippling:
                        return 3408;
                    default:
                        return 0;
                }
            }
        }
        // private static bool ThrownPoison
        //  {
        //get
        // {
        //  return StyxWoW.Me.Inventory.Equipped.Ranged != null &&
        //      StyxWoW.Me.Inventory.Equipped.Ranged.TemporaryEnchantment.Id == 0;
        //  }
        //  }


        public static void ThrowPoison()
        {
            WoWItem Main = GetPoison(ClassSettings._Instance.SubtletyMainPoison);
            WoWItem OffHand = GetPoison(ClassSettings._Instance.SubtletyOffHandPoison);

            if (Poisons2.NeedPoisonMainHand)
            {
               
                Log.Write("Applying [{0}] to main hand", Main.Name);
                Navigator.PlayerMover.MoveStop();
                StyxWoW.SleepForLagDuration();
                Main.UseContainerItem();
                StyxWoW.SleepForLagDuration();
                SpellManager.CastSpellById(MainHandPoison);
                StyxWoW.SleepForLagDuration();
                Thread.Sleep(1000); // Ugly <---- 
                while (StyxWoW.Me.IsCasting)
                {
                    Thread.Sleep(100);
                }
                StyxWoW.SleepForLagDuration();
                Thread.Sleep(1000);

                return;
            }
            if (Poisons2.NeedOffHandPoison)
            {
                
                Log.Write("Applying [{0}] to OffHand", OffHand.Name);
                Navigator.PlayerMover.MoveStop();
                StyxWoW.SleepForLagDuration();
                Main.UseContainerItem();
                StyxWoW.SleepForLagDuration();
                SpellManager.CastSpellById(OffHandHandPoison);
                StyxWoW.SleepForLagDuration();
                Thread.Sleep(1000); // Ugly <---- 
                while (StyxWoW.Me.IsCasting)
                {
                    Thread.Sleep(100);
                }
                StyxWoW.SleepForLagDuration();
                Thread.Sleep(1000);

                return;
            }
        }




        public static WoWItem GetPoison(ePoison Poison)
        {
            switch (Poison)
            {
                case ePoison.Instant:
                    return
                        StyxWoW.Me.CarriedItems.Where(i => InstantID.Contains(i.Entry)).OrderByDescending(i => i.Entry).
                            FirstOrDefault();
                case ePoison.MindNumbing:
                    return
                        StyxWoW.Me.CarriedItems.Where(i => MindNumbingID.Contains(i.Entry)).OrderByDescending(
                            i => i.Entry).FirstOrDefault();
                case ePoison.Deadly:
                    return
                        StyxWoW.Me.CarriedItems.Where(i => DeadlyID.Contains(i.Entry)).OrderByDescending(i => i.Entry).
                            FirstOrDefault();
                case ePoison.Wound:
                    return
                        StyxWoW.Me.CarriedItems.Where(i => WoundID.Contains(i.Entry)).OrderByDescending(i => i.Entry).
                            FirstOrDefault();
            }

            return null;
        }
    }
}*/
        


    


